package edu.the.last.chord.factory.random;

import java.util.Random;

import edu.the.last.Messages;
import edu.the.last.chord.factory.ChordInterface;

/**
 * a strategy that suggest totally random chords (for demonstration purpose
 * only)
 * 
 * @author albertcsani
 * 
 */
public class RandomChord implements ChordInterface {
	private String chords[] = null;
	private String chordPrim[] = { Messages.getString("RandomChord.0"), Messages.getString("RandomChord.1"), Messages.getString("RandomChord.2"), Messages.getString("RandomChord.3"), Messages.getString("RandomChord.4"), Messages.getString("RandomChord.5"), Messages.getString("RandomChord.6"), Messages.getString("RandomChord.7"), Messages.getString("RandomChord.8"), Messages.getString("RandomChord.9"), Messages.getString("RandomChord.10"), Messages.getString("RandomChord.11"), Messages.getString("RandomChord.12"), Messages.getString("RandomChord.13"), Messages.getString("RandomChord.14"), Messages.getString("RandomChord.15"), Messages.getString("RandomChord.16"), Messages.getString("RandomChord.17"), Messages.getString("RandomChord.18"), Messages.getString("RandomChord.19"), Messages.getString("RandomChord.20"), Messages.getString("RandomChord.21"), Messages.getString("RandomChord.22"), Messages.getString("RandomChord.23") }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$ //$NON-NLS-11$ //$NON-NLS-12$ //$NON-NLS-13$ //$NON-NLS-14$ //$NON-NLS-15$ //$NON-NLS-16$ //$NON-NLS-17$ //$NON-NLS-18$ //$NON-NLS-19$ //$NON-NLS-20$ //$NON-NLS-21$ //$NON-NLS-22$ //$NON-NLS-23$ //$NON-NLS-24$

	@Override
	public String toString() {
		return Messages.getString("RandomChord.Random"); //$NON-NLS-1$
	}

	@Override
	public String[] getChords(int[] sounds, int bpb, int bpm) {
		Random rnd = new Random();
		int noOfChords = sounds.length / 2 / bpb + 1;
		chords = new String[noOfChords];
		for (int i = 0; i < noOfChords; i++) {
			chords[i] = chordPrim[rnd.nextInt(chordPrim.length)];
		}
		return chords;
	}

}
